<?php
namespace app\admin\event\listeners\finance;

use app\admin\logic\system\Log;
use app\user\logic\user\SystemNotify;

/**
 * 后台审核提现后操作
 */
class Encashment
{
    public static function handle($data)
    {

        // 操作日志
        Log::write('管理员审核', 'encashment', 'examine');

        // 参数
        $status  = $data['encashment_data']->status;
        $user_id = $data['encashment_data']->user_id;
        $money   = $data['encashment_data']->money;
        $config  = $data['notify_config'];

        switch ($status) {

            case 2:
                $msg = "您的提现审核已通过，提现金额为：" . $money;
                break;

            case 3:
                $msg = "您的提现审核未通过，提现金额为：" . $money;
                break;

            default:
                # code...
                break;
        }

        // 发送系统信息通知用户
        if ($config['notify'] ?? false) {
            $re = app(SystemNotify::class)::create([
                'user_id'     => $user_id,
                'title'       => '提现审核',
                'content'     => $msg,
                'notify_type' => 0,
            ]);
        }

        // 发送短信通知用户
        if ($config['sms'] ?? false) {

        }
    }
}
